<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Yaf_Dispatcher 类</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="class.yaf-bootstrap-abstract.html">« Yaf_Bootstrap_Abstract</a></li>
      <li style="float: right;"><a href="yaf-dispatcher.autorender.html">Yaf_Dispatcher::autoRender »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="book.yaf.html">Yaf</a></li>
    <li>Yaf_Dispatcher 类</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="class.yaf-dispatcher" class="reference">

 <h1 class="title">Yaf_Dispatcher 类</h1>
 

 <div class="partintro"><p class="verinfo">(Yaf &gt;=1.0.0)</p>


  <div class="section" id="yaf-dispatcher.intro">
   <h2 class="title">简介</h2>
   <p class="para">
    <span class="classname"><strong class="classname">Yaf_Dispatcher</strong></span>用于初始化处理请求的运行环境, 
    它协调路由来的请求, 并分发和执行发现的动作, 
    然后收集动作产生的响应, 输出响应给请求者, 并在整个过程完成以后返回响应.
   </p>
   <p class="para">
    <span class="classname"><strong class="classname">Yaf_Dispatcher</strong></span>是单例模式运行的, 
    也就是说自始至终只生成一个<span class="classname"><strong class="classname">Yaf_Dispatcher</strong></span>实例, 
    因此, 可以把它看成是在分发过程中生成的对象的注册表, 可以从中获取到分发过程中产生的对象.
   </p>
  </div>


  <div class="section" id="yaf-dispatcher.synopsis">
   <h2 class="title">类摘要</h2>


   <div class="classsynopsis">
    <div class="ooclass"></div>


    <div class="classsynopsisinfo">
     <span class="ooclass">
      <span class="modifier">final</span>
      <span class="modifier">class</span> <strong class="classname">Yaf_Dispatcher</strong>
     </span>
     {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 属性 */</div>
    <div class="fieldsynopsis">
     <span class="modifier">protected</span>
      <var class="varname"><a href="class.yaf-dispatcher.html#yaf-dispatcher.props.router">$<var class="varname">_router</var></a></var>;</div>

    <div class="fieldsynopsis"><span class="modifier">protected</span>
      <var class="varname"><a href="class.yaf-dispatcher.html#yaf-dispatcher.props.view">$<var class="varname">_view</var></a></var>;</div>

    <div class="fieldsynopsis"><span class="modifier">protected</span>
      <var class="varname"><a href="class.yaf-dispatcher.html#yaf-dispatcher.props.request">$<var class="varname">_request</var></a></var>;</div>

    <div class="fieldsynopsis"><span class="modifier">protected</span>
      <var class="varname"><a href="class.yaf-dispatcher.html#yaf-dispatcher.props.plugins">$<var class="varname">_plugins</var></a></var>;</div>

    <div class="fieldsynopsis"><span class="modifier">protected</span>
     <span class="modifier">static</span>
      <var class="varname"><a href="class.yaf-dispatcher.html#yaf-dispatcher.props.instance">$<var class="varname">_instance</var></a></var>;</div>

    <div class="fieldsynopsis"><span class="modifier">protected</span>
      <var class="varname"><a href="class.yaf-dispatcher.html#yaf-dispatcher.props.auto-render">$<var class="varname">_auto_render</var></a></var>;</div>

    <div class="fieldsynopsis"><span class="modifier">protected</span>
      <var class="varname"><a href="class.yaf-dispatcher.html#yaf-dispatcher.props.return-response">$<var class="varname">_return_response</var></a></var>;</div>

    <div class="fieldsynopsis"><span class="modifier">protected</span>
      <var class="varname"><a href="class.yaf-dispatcher.html#yaf-dispatcher.props.instantly-flush">$<var class="varname">_instantly_flush</var></a></var>;</div>

    <div class="fieldsynopsis"><span class="modifier">protected</span>
      <var class="varname"><a href="class.yaf-dispatcher.html#yaf-dispatcher.props.default-module">$<var class="varname">_default_module</var></a></var>;</div>

    <div class="fieldsynopsis"><span class="modifier">protected</span>
      <var class="varname"><a href="class.yaf-dispatcher.html#yaf-dispatcher.props.default-controller">$<var class="varname">_default_controller</var></a></var>;</div>

    <div class="fieldsynopsis"><span class="modifier">protected</span>
      <var class="varname"><a href="class.yaf-dispatcher.html#yaf-dispatcher.props.default-action">$<var class="varname">_default_action</var></a></var>;</div>


    
    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="yaf-dispatcher.autorender.html" class="methodname">autoRender</a></span>(<span class="methodparam"><span class="type">bool</span> <code class="parameter">$flag</code></span>): <span class="type"><a href="class.yaf-dispatcher.html" class="type Yaf_Dispatcher">Yaf_Dispatcher</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="yaf-dispatcher.catchexception.html" class="methodname">catchException</a></span>(<span class="methodparam"><span class="type">bool</span> <code class="parameter">$flag</code><span class="initializer"> = ?</span></span>): <span class="type"><a href="class.yaf-dispatcher.html" class="type Yaf_Dispatcher">Yaf_Dispatcher</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span><span class="methodname"><a href="yaf-dispatcher.construct.html" class="methodname">__construct</a></span>()</div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="yaf-dispatcher.disableview.html" class="methodname">disableView</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="yaf-dispatcher.dispatch.html" class="methodname">dispatch</a></span>(<span class="methodparam"><span class="type"><a href="class.yaf-request-abstract.html" class="type Yaf_Request_Abstract">Yaf_Request_Abstract</a></span> <code class="parameter">$request</code></span>): <span class="type"><a href="class.yaf-response-abstract.html" class="type Yaf_Response_Abstract">Yaf_Response_Abstract</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="yaf-dispatcher.enableview.html" class="methodname">enableView</a></span>(): <span class="type"><a href="class.yaf-dispatcher.html" class="type Yaf_Dispatcher">Yaf_Dispatcher</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="yaf-dispatcher.flushinstantly.html" class="methodname">flushInstantly</a></span>(<span class="methodparam"><span class="type">bool</span> <code class="parameter">$flag</code></span>): <span class="type"><a href="class.yaf-dispatcher.html" class="type Yaf_Dispatcher">Yaf_Dispatcher</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="yaf-dispatcher.getapplication.html" class="methodname">getApplication</a></span>(): <span class="type"><a href="class.yaf-application.html" class="type Yaf_Application">Yaf_Application</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="yaf-dispatcher.getdefaultaction.html" class="methodname">getDefaultAction</a></span>(): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="yaf-dispatcher.getdefaultcontroller.html" class="methodname">getDefaultController</a></span>(): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="yaf-dispatcher.getdefaultmodule.html" class="methodname">getDefaultModule</a></span>(): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><a href="yaf-dispatcher.getinstance.html" class="methodname">getInstance</a></span>(): <span class="type"><a href="class.yaf-dispatcher.html" class="type Yaf_Dispatcher">Yaf_Dispatcher</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="yaf-dispatcher.getrequest.html" class="methodname">getRequest</a></span>(): <span class="type"><a href="class.yaf-request-abstract.html" class="type Yaf_Request_Abstract">Yaf_Request_Abstract</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="yaf-dispatcher.getrouter.html" class="methodname">getRouter</a></span>(): <span class="type"><a href="class.yaf-router.html" class="type Yaf_Router">Yaf_Router</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="yaf-dispatcher.initview.html" class="methodname">initView</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$templates_dir</code></span>, <span class="methodparam"><span class="type">array</span> <code class="parameter">$options</code><span class="initializer"> = ?</span></span>): <span class="type"><a href="class.yaf-view-interface.html" class="type Yaf_View_Interface">Yaf_View_Interface</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="yaf-dispatcher.registerplugin.html" class="methodname">registerPlugin</a></span>(<span class="methodparam"><span class="type"><a href="class.yaf-plugin-abstract.html" class="type Yaf_Plugin_Abstract">Yaf_Plugin_Abstract</a></span> <code class="parameter">$plugin</code></span>): <span class="type"><a href="class.yaf-dispatcher.html" class="type Yaf_Dispatcher">Yaf_Dispatcher</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="yaf-dispatcher.returnresponse.html" class="methodname">returnResponse</a></span>(<span class="methodparam"><span class="type">bool</span> <code class="parameter">$flag</code></span>): <span class="type"><a href="class.yaf-dispatcher.html" class="type Yaf_Dispatcher">Yaf_Dispatcher</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="yaf-dispatcher.setdefaultaction.html" class="methodname">setDefaultAction</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$action</code></span>): <span class="type"><a href="class.yaf-dispatcher.html" class="type Yaf_Dispatcher">Yaf_Dispatcher</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="yaf-dispatcher.setdefaultcontroller.html" class="methodname">setDefaultController</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$controller</code></span>): <span class="type"><a href="class.yaf-dispatcher.html" class="type Yaf_Dispatcher">Yaf_Dispatcher</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="yaf-dispatcher.setdefaultmodule.html" class="methodname">setDefaultModule</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$module</code></span>): <span class="type"><a href="class.yaf-dispatcher.html" class="type Yaf_Dispatcher">Yaf_Dispatcher</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="yaf-dispatcher.seterrorhandler.html" class="methodname">setErrorHandler</a></span>(<span class="methodparam"><span class="type"><span class="type call">call</span></span> <code class="parameter">$callback</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$error_types</code></span>): <span class="type"><a href="class.yaf-dispatcher.html" class="type Yaf_Dispatcher">Yaf_Dispatcher</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="yaf-dispatcher.setrequest.html" class="methodname">setRequest</a></span>(<span class="methodparam"><span class="type"><a href="class.yaf-request-abstract.html" class="type Yaf_Request_Abstract">Yaf_Request_Abstract</a></span> <code class="parameter">$request</code></span>): <span class="type"><a href="class.yaf-dispatcher.html" class="type Yaf_Dispatcher">Yaf_Dispatcher</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="yaf-dispatcher.setview.html" class="methodname">setView</a></span>(<span class="methodparam"><span class="type"><a href="class.yaf-view-interface.html" class="type Yaf_View_Interface">Yaf_View_Interface</a></span> <code class="parameter">$view</code></span>): <span class="type"><a href="class.yaf-dispatcher.html" class="type Yaf_Dispatcher">Yaf_Dispatcher</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="yaf-dispatcher.throwexception.html" class="methodname">throwException</a></span>(<span class="methodparam"><span class="type">bool</span> <code class="parameter">$flag</code><span class="initializer"> = ?</span></span>): <span class="type"><a href="class.yaf-dispatcher.html" class="type Yaf_Dispatcher">Yaf_Dispatcher</a></span></div>

   }</div>


  </div>

  

  <div class="section" id="yaf-dispatcher.props">
   <h2 class="title">属性</h2>
   <dl>
    
     <dt id="yaf-dispatcher.props.router"><var class="varname">_router</var></dt>

     <dd>

      <p class="para"/>
     </dd>

    
    
     <dt id="yaf-dispatcher.props.view"><var class="varname">_view</var></dt>

     <dd>

      <p class="para"/>
     </dd>

    
    
     <dt id="yaf-dispatcher.props.request"><var class="varname">_request</var></dt>

     <dd>

      <p class="para"/>
     </dd>

    
    
     <dt id="yaf-dispatcher.props.plugins"><var class="varname">_plugins</var></dt>

     <dd>

      <p class="para"/>
     </dd>

    
    
     <dt id="yaf-dispatcher.props.instance"><var class="varname">_instance</var></dt>

     <dd>

      <p class="para"/>
     </dd>

    
    
     <dt id="yaf-dispatcher.props.auto-render"><var class="varname">_auto_render</var></dt>

     <dd>

      <p class="para"/>
     </dd>

    
    
     <dt id="yaf-dispatcher.props.return-response"><var class="varname">_return_response</var></dt>

     <dd>

      <p class="para"/>
     </dd>

    
    
     <dt id="yaf-dispatcher.props.instantly-flush"><var class="varname">_instantly_flush</var></dt>

     <dd>

      <p class="para"/>
     </dd>

    
    
     <dt id="yaf-dispatcher.props.default-module"><var class="varname">_default_module</var></dt>

     <dd>

      <p class="para"/>
     </dd>

    
    
     <dt id="yaf-dispatcher.props.default-controller"><var class="varname">_default_controller</var></dt>

     <dd>

      <p class="para"/>
     </dd>

    
    
     <dt id="yaf-dispatcher.props.default-action"><var class="varname">_default_action</var></dt>

     <dd>

      <p class="para"/>
     </dd>

    
   </dl>

  </div>



 </div>

 









































































































































































<h2>目录</h2><ul class="chunklist chunklist_reference"><li><a href="yaf-dispatcher.autorender.html">Yaf_Dispatcher::autoRender</a> — 开启/关闭自动渲染功能</li><li><a href="yaf-dispatcher.catchexception.html">Yaf_Dispatcher::catchException</a> — 开启/关闭自动异常捕获功能</li><li><a href="yaf-dispatcher.construct.html">Yaf_Dispatcher::__construct</a> — Yaf_Dispatcher 构造函数</li><li><a href="yaf-dispatcher.disableview.html">Yaf_Dispatcher::disableView</a> — 关闭自动渲染</li><li><a href="yaf-dispatcher.dispatch.html">Yaf_Dispatcher::dispatch</a> — 分发请求</li><li><a href="yaf-dispatcher.enableview.html">Yaf_Dispatcher::enableView</a> — 开启自动渲染</li><li><a href="yaf-dispatcher.flushinstantly.html">Yaf_Dispatcher::flushInstantly</a> — 打开关闭自动响应</li><li><a href="yaf-dispatcher.getapplication.html">Yaf_Dispatcher::getApplication</a> — 获取当前的Yaf_Application实例</li><li><a href="yaf-dispatcher.getdefaultaction.html">Yaf_Dispatcher::getDefaultAction</a> — Retrive the default action name</li><li><a href="yaf-dispatcher.getdefaultcontroller.html">Yaf_Dispatcher::getDefaultController</a> — Retrive the default controller name</li><li><a href="yaf-dispatcher.getdefaultmodule.html">Yaf_Dispatcher::getDefaultModule</a> — Retrive the default module name</li><li><a href="yaf-dispatcher.getinstance.html">Yaf_Dispatcher::getInstance</a> — 获取当前的Yaf_Dispatcher实例</li><li><a href="yaf-dispatcher.getrequest.html">Yaf_Dispatcher::getRequest</a> — 获取当前的请求实例</li><li><a href="yaf-dispatcher.getrouter.html">Yaf_Dispatcher::getRouter</a> — 获取路由器</li><li><a href="yaf-dispatcher.initview.html">Yaf_Dispatcher::initView</a> — 初始化视图引擎并返回它</li><li><a href="yaf-dispatcher.registerplugin.html">Yaf_Dispatcher::registerPlugin</a> — 注册一个插件</li><li><a href="yaf-dispatcher.returnresponse.html">Yaf_Dispatcher::returnResponse</a> — The returnResponse purpose</li><li><a href="yaf-dispatcher.setdefaultaction.html">Yaf_Dispatcher::setDefaultAction</a> — 设置路由的默认动作</li><li><a href="yaf-dispatcher.setdefaultcontroller.html">Yaf_Dispatcher::setDefaultController</a> — 设置路由的默认控制器</li><li><a href="yaf-dispatcher.setdefaultmodule.html">Yaf_Dispatcher::setDefaultModule</a> — 设置路由的默认模块</li><li><a href="yaf-dispatcher.seterrorhandler.html">Yaf_Dispatcher::setErrorHandler</a> — 设置错误处理函数</li><li><a href="yaf-dispatcher.setrequest.html">Yaf_Dispatcher::setRequest</a> — The setRequest purpose</li><li><a href="yaf-dispatcher.setview.html">Yaf_Dispatcher::setView</a> — 设置视图引擎</li><li><a href="yaf-dispatcher.throwexception.html">Yaf_Dispatcher::throwException</a> — 开启/关闭异常抛出</li></ul>
</div>
</div></div></body></html>